<template>
  <div>
    <!-- 申请列表 -->
    <div v-show="showList">

      <el-tabs v-model="activeName" @tab-click="handleClickTab">
        <el-tab-pane label="入住申请" name="first"></el-tab-pane>
        <el-tab-pane label="退宿申请" name="second"></el-tab-pane>
        <el-tab-pane label="调寝申请" name="third"></el-tab-pane>
        <el-tab-pane label="修改院系申请" name="fourth"></el-tab-pane>
      </el-tabs>

      <el-form size="small" :inline="true" v-show="activeName != 'fourth'">
        <!-- <el-form-item label="开始时间" style="font-weight:bold;">
          <el-date-picker v-model="queryParams.beginDate" type="date" placeholder="选择日期" format="yyyy 年 MM 月 dd 日"
            value-format="yyyy-MM-dd" style="width:180px;" clearable>
          </el-date-picker>
        </el-form-item> -->
        <el-form-item label="开始时间" style="font-weight:bold;">
          <el-date-picker v-model="queryParams.starteTime" type="date" placeholder="选择日期" format="yyyy 年 MM 月 dd 日"
            value-format="yyyy-MM-dd" style="width:180px;" clearable>
          </el-date-picker>
        </el-form-item>
        <el-form-item label="结束时间" style="font-weight:bold;">
          <el-date-picker v-model="queryParams.endTime" type="date" placeholder="选择日期" format="yyyy 年 MM 月 dd 日"
            value-format="yyyy-MM-dd" style="width:180px;" clearable>
          </el-date-picker>
        </el-form-item>
        <el-form-item label="申请人">
          <el-input v-model="queryParams.name" placeholder="请输入" style="width:150px;"></el-input>
        </el-form-item>
        <el-form-item label="院 系" style="font-weight:bold;">
          <el-select :disabled="clientRole == 2" v-model="queryParams.collegeId" placeholder="请选择院系" style="width:200px;"
            clearable>
            <el-option v-for="item in CollegeName" :key="item.id" :label="item.name" :value="item.id"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="申请状态" style="font-weight:bold;">
          <el-select v-model="queryParams.businessState" placeholder="请选择" style="width:150px;" clearable>
            <el-option label="进行中" value="0"></el-option>
            <el-option label="已通过" value="1"></el-option>
            <el-option label="已拒绝" value="2"></el-option>
          </el-select>
        </el-form-item>
        <el-button size="small" class="search_button" type="primary" icon="el-icon-search" @click="getList">查询</el-button>
        <el-button size="small" plain class="reset_button" type="info" icon="el-icon-refresh"
          @click="reset">重置</el-button>
      </el-form>

      <el-form size="small" :model="form" :inline="true" v-show="activeName == 'fourth'">
        <el-form-item label="申请人">
          <el-input v-model="form.name" placeholder="请输入" style="width:200px;"></el-input>
        </el-form-item>
        <el-form-item label="申请状态" style="font-weight:bold;">
          <el-select v-model="form.businessState" placeholder="请选择申请状态" style="width:200px;" clearable>
            <el-option label="待审核" value="0"></el-option>
            <el-option label="通过" value="1"></el-option>
            <el-option label="拒绝" value="2"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="院 系" style="font-weight:bold;">
          <el-select :disabled="clientRole == 2" v-model="form.collegeId" placeholder="请选择院系" style="width:200px;"
            clearable>
            <el-option v-for="item in CollegeName" :key="item.id" :label="item.name" :value="item.id"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="开始时间" style="font-weight:bold;">
          <el-date-picker v-model="form.starteTime" type="date" placeholder="选择日期" format="yyyy 年 MM 月 dd 日"
            value-format="yyyy-MM-dd" style="width:180px;" clearable>
          </el-date-picker>
        </el-form-item>
        <!-- <el-form-item label="申请时间段" style="font-weight:bold;">
          <el-date-picker v-model="form.time" type="daterange" range-separator="至" start-placeholder="开始日期"
            end-placeholder="结束日期">
          </el-date-picker>
        </el-form-item> -->
        <el-button size="small" class="search_button" type="primary" icon="el-icon-search"
          @click="getListCollege">查询</el-button>
        <el-button size="small" class="reset_button" icon="el-icon-refresh" @click="resetCollege">重置</el-button>
      </el-form>

      <el-button class="exportBtn" size="small" type="success" plain icon="el-icon-download" @click="exportExcel"
        v-show="activeName == 'first'">导出入住申请数据</el-button>
      <el-button class="exportBtn" size="small" type="success" plain icon="el-icon-download" @click="exportExcel"
        v-show="activeName == 'second'">导出退宿申请数据</el-button>
      <el-button class="exportBtn" size="small" type="success" plain icon="el-icon-download" @click="exportExcel"
        v-show="activeName == 'third'">导出调寝申请数据</el-button>

      <!-- 表格 -->
      <el-table :data="tableData" style="width: 100%;margin-top:10px" border size="medium"
        v-show="activeName != 'fourth'">
        <el-table-column type="index" width="50">
        </el-table-column>
        <el-table-column prop="userName" label="申请人" align="center"></el-table-column>
        <el-table-column prop="userNum" label="学号" align="center"></el-table-column>
        <el-table-column prop="collegeName" label="学院" align="center"></el-table-column>
        <el-table-column prop="mobile" label="手机号" align="center"></el-table-column>
        <el-table-column prop="time" label="申请时间" align="center"></el-table-column>
        <el-table-column prop="reason" label="申请原因" align="center"></el-table-column>
        <el-table-column prop="businessState" label="申请状态" align="center">
          <template slot-scope="scope">
            <el-button type="success" plain v-if="scope.row.businessState == 0" disabled>进行中</el-button>
            <el-button type="primary" plain v-if="scope.row.businessState == 1" disabled>已通过</el-button>
            <el-button type="danger" plain v-if="scope.row.businessState == 2" disabled>已拒绝</el-button>
          </template>
        </el-table-column>
        <el-table-column prop="handle" label="操作" align="center">
          <template slot-scope="scope">
            <el-button size="mini" type="primary" plain @click="handleTask(scope.row)">查看详情</el-button>
            <el-button size="mini" type="danger"  plain @click="removeTask({ id: scope.row.id })">删除</el-button>
          </template>
          
        </el-table-column>
      </el-table>

      <!-- 表格 -->
      <el-table size="medium" :data="tableDataCollege" tooltip-effect="dark" style="width: 100%" border
        v-show="activeName == 'fourth'">
        <el-table-column prop="userName" label="申请人" align="center"></el-table-column>
        <el-table-column prop="userNum" label="学号" align="center"></el-table-column>
        <el-table-column prop="collegeName" label="学院" align="center"></el-table-column>

        <!-- <el-table-column prop="roomNum" label="住宿信息" align="center"></el-table-column> -->
        <!-- <el-table-column prop="businessType" label="申请类型" align="center">
          <template slot-scope="scope">
            <span v-if="(scope.row.businessType == 1)">入住申请</span>
            <span v-if="(scope.row.businessType == 2)">退宿申请</span>
            <span v-if="(scope.row.businessType == 3)">调寝申请</span>
            <span v-if="(scope.row.businessType == 4)">学生学院修改申请</span>
            <span v-if="(scope.row.businessType == 5)">教职工学院修改申请</span>
          </template>
        </el-table-column> -->
        <el-table-column prop="reason" label="申请理由" align="center"></el-table-column>
        <el-table-column prop="time" label="申请时间" align="center" width="160"></el-table-column>
        <el-table-column prop="businessState" label="申请状态" align="center">
          <template slot-scope="scope">
            <el-button type="success" plain v-if="scope.row.businessState == 0" disabled>进行中</el-button>
            <el-button type="primary" plain v-if="scope.row.businessState == 1" disabled>已通过</el-button>
            <el-button type="danger" plain v-if="scope.row.businessState == 2" disabled>已拒绝</el-button>
          </template>
        </el-table-column>
        <el-table-column prop="adminName" label="审批人" align="center" width="160"></el-table-column>
        <el-table-column prop="applyReason" label="审批意见" align="center" width="160"></el-table-column>
        <el-table-column prop="applyTime" label="审批时间" align="center" width="160"></el-table-column>
        <el-table-column label="操作" align="center">
          <template slot-scope="scope">
            <el-button size="mini" type="danger"  plain @click="removeTask({ id: scope.row.id })">删除</el-button>
          </template>
        </el-table-column>
      </el-table>

      <el-pagination class="pagination" background layout="total, sizes, prev, pager, next, jumper" :total="totalCollege"
        :page-size="10" :page-sizes="[10, 20, 30, 40]" @current-change="handleCurrentChangeCollege"
        @size-change="handleSizeChangeCollege" v-show="activeName == 'fourth'"></el-pagination>

      <el-pagination class="pagination" background layout="total, sizes, prev, pager, next, jumper" :total="total"
        :page-size="10" :page-sizes="[10, 20, 30, 40]" @current-change="handleCurrentChange"
        @size-change="handleSizeChange" v-show="activeName != 'fourth'"></el-pagination>


      <!-- <el-dialog title="申请详情" :visible.sync="showDetail" width="800px" style="margin-top:10px" append-to-body>
        <el-descriptions class="margin-top" title="申请人信息" :column="3" size="mini" border>
          <el-descriptions-item>
            <template slot="label">
              <i class="el-icon-user"></i>
              申请人
            </template>
            {{ userInfo.userName }}
          </el-descriptions-item>
          <el-descriptions-item>
            <template slot="label">
              <i class="el-icon-mobile-phone"></i>
              <span v-show="userInfo.businessType == 5">工号</span>
              <span v-show="userInfo.businessType != 5">学号</span>
            </template>
            {{ userInfo.userNum }}
          </el-descriptions-item>
          <el-descriptions-item>
            <template slot="label">
              <i class="el-icon-location-outline"></i>
              学院
            </template>
            {{ userInfo.collegeName }}
          </el-descriptions-item>
          <el-descriptions-item>
            <template slot="label">
              <i class="el-icon-office-building"></i>
              住宿信息
            </template>
            {{ userInfo.campusName }} {{ userInfo.buildName }} {{ userInfo.roomNum }} {{ userInfo.bedCode }}
          </el-descriptions-item>
          <el-descriptions-item>
            <template slot="label">
              <i class="el-icon-s-check"></i>
              签名
            </template>
            <el-button size="mini" type="primary" plain @click="showSignSelf = true">查看</el-button>
            <el-dialog title="签名" :visible.sync="showSignSelf" width="400px" style="margin-top:10px" append-to-body>
              <img :src="userInfo.imgUrl" alt="" style="width:200px">
            </el-dialog>
          </el-descriptions-item>
        </el-descriptions>
        <el-descriptions style="margin-top:10px;" class="margin-top" title="审批人信息" :column="3" size="mini" border
          v-for="item in examine" :key="item.adminId">
          <el-descriptions-item>
            <template slot="label">
              <i class="el-icon-user"></i>
              <span v-show="item.clientRole == 1">辅导员</span>
              <span v-show="item.clientRole == 2">院领导</span>
              <span v-show="item.clientRole == 3">楼长</span>
              <span v-show="item.clientRole == 4">后勤办公室</span>
              <span v-show="item.clientRole == 5">财务处</span>
              <span v-show="item.clientRole == 6">单校区负责人</span>
              <span v-show="item.clientRole == 7">保卫处</span>
            </template>
            {{ item.adminName }}
          </el-descriptions-item>
          <el-descriptions-item>
            <template slot="label">
              <i class="el-icon-s-check"></i>
              签名
            </template>
            <el-button size="mini" type="primary" plain @click="showSign(item.imgUrl)">查看</el-button>
            <el-dialog title="签名" :visible.sync="showSignOther" width="400px" style="margin-top:10px" append-to-body>
              <img :src="nowImgUrl" alt="" style="width:200px">
            </el-dialog>
          </el-descriptions-item>
          <el-descriptions-item>
            <template slot="label">
              <i class="el-icon-location-outline"></i>
              审批结果
            </template>
            <el-tag size="small" v-show="item.result == 0" type="success">同意</el-tag>
            <el-tag size="small" v-show="item.result == 1" type="danger">拒绝</el-tag>
            <el-tag size="small" v-show="!item.result" type="info">待审批</el-tag>
          </el-descriptions-item>
          <el-descriptions-item>
            <template slot="label">
              <i class="el-icon-mobile-phone"></i>
              审批意见
            </template>
            {{ item.reason }}
          </el-descriptions-item>
          <el-descriptions-item>
            <template slot="label">
              <i class="el-icon-location-outline"></i>
              审批时间
            </template>
            <span>{{ item.modifyTime }}</span>
          </el-descriptions-item>
        </el-descriptions>
      </el-dialog> -->

    </div>

    <div v-show="showList == false">
      <el-form label-width="100px">
        <div style="width: 100%;height:40px;">
          <el-button @click="showList = true" type="primary"
            style="width: 100px;font-size:14px;float:right;margin-right:200px;">返
            回</el-button>
        </div>

        <el-card shadow="hover" style="margin-bottom: 20px;margin-top:20px;">
          <div slot="header" v-show="activeName == 'first'">
            <span style="font-weight: bold;font-size:18px;">入住流程步骤</span>
          </div>
          <div slot="header" v-show="activeName == 'second'">
            <span style="font-weight: bold;font-size:18px;">退宿流程步骤</span>
          </div>
          <div slot="header" v-show="activeName == 'third'">
            <span style="font-weight: bold;font-size:18px;">调寝流程步骤</span>
          </div>
          <el-steps :active="flowList.length - 1" v-show="activeName == 'first'">
            <el-step title="学生申请" icon="el-icon-video-play"></el-step>
            <el-step title="辅导员审批" icon="el-icon-video-play"></el-step>
            <el-step title="学院书记审批" icon="el-icon-video-play"></el-step>
            <el-step title="后勤办公室审批" icon="el-icon-video-play"></el-step>
            <el-step title="财务处审批" icon="el-icon-video-play"></el-step>
          </el-steps>
          <el-steps :active="flowList.length - 1" v-show="activeName == 'second'">
            <el-step title="学生申请" icon="el-icon-video-play"></el-step>
            <el-step title="辅导员审批" icon="el-icon-video-play"></el-step>
            <el-step title="学院书记审批" icon="el-icon-video-play"></el-step>
            <el-step title="原楼长审批" icon="el-icon-video-play"></el-step>
            <el-step title="后勤办公室审批" icon="el-icon-video-play"></el-step>
            <el-step title="财务处审批" icon="el-icon-video-play"></el-step>
          </el-steps>
          <el-steps :active="flowList.length - 1" v-show="activeName == 'third'">
            <el-step title="学生申请" icon="el-icon-video-play"></el-step>
            <el-step title="辅导员审批" icon="el-icon-video-play"></el-step>
            <el-step title="学院书记审批" icon="el-icon-video-play"></el-step>
            <el-step title="原楼长审批" icon="el-icon-video-play"></el-step>
            <el-step title="现楼长审批" icon="el-icon-video-play"></el-step>
            <el-step title="后勤办公室审批" icon="el-icon-video-play"></el-step>
            <el-step title="财务处审批" icon="el-icon-video-play"></el-step>
          </el-steps>
        </el-card>

        <el-card shadow="hover" style="margin-bottom: 20px;">
          <div slot="header">
            <span style="font-weight: bold;font-size:18px;">学生申请信息</span>
          </div>
          <div class="infoItem"><span id="colorTitle">姓名</span> {{ stu.name }}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span
              id="colorTitle">手机号</span> {{ stu.phone }}</div>
          <div class="infoItem"><span id="colorTitle">学号</span> {{ stu.num }}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span
              id="colorTitle">学院</span> {{ stu.collegeName }}</div>
          <div class="infoItem"><span id="colorTitle">申请理由</span> {{ stu.reason }}</div>
          <div class="infoItem" v-if="oldInfo"><span id="colorTitle">原床位信息</span> {{ oldInfo.oldCampus }} {{
            oldInfo.oldBuild }} {{
    oldInfo.oldDorm
  }} {{ oldInfo.oldBed }} &nbsp;&nbsp;({{ oldInfo.num }})</div>
          <div class="infoItem" v-if="newInfo"><span id="colorTitle">新床位信息</span> {{ newInfo.newCampus }} {{
            newInfo.newBuild }} {{
    newInfo.newDorm
  }} {{ newInfo.newBed }} &nbsp;&nbsp;({{ newInfo.num }})</div>
        </el-card>

        <el-card shadow="hover">
          <div slot="header">
            <span style="font-weight: bold;font-size:18px;">当前流程信息</span>
          </div>
          <el-row type="flex" class="row-bg">
            <el-timeline>
              <el-timeline-item v-for="flow in flowList" :key="flow.id" :color="flow.endTime ? '#1890FF' : ''"
                :timestamp="flow.endTime" placement="top">
                <el-card shadow=" hover">
                  <p v-if="flow.historyActivityName == '开始'">流程开始</p>
                  <p v-if="flow.historyActivityName == '结束'">流程结束</p>
                  <p v-if="flow.historyActivityName != '开始' && flow.historyActivityName != '结束'"><span id="colorTitle">{{
                    flow.historyActivityName }}</span> {{ flow.assigneeName }}</p>
                  <p v-if="flow.historyActivityName != '开始' && flow.historyActivityName != '结束'">任务历时 {{
                    flow.historyActivityDurationTime }}</p>
                  <p v-if="flow.historyActivityName != '开始' && flow.historyActivityName != '结束'">批复意见: {{ flow.comment }}
                  </p>
                </el-card>
              </el-timeline-item>
            </el-timeline>
          </el-row>
        </el-card>
      </el-form>
    </div>
  </div>
</template>

<script>
import {
  getList, //获取列表
  exportExcel //导出列表
} from '_api/MyBusiness/index.js'
import {
  modelView,
  getStuInfo
  // 查看流程
} from '_api/FlowManage/flowManage/index.js'
import { getListApply, lookDetail } from "_api/DormManage/Apply/index.js"
import { getCollegeName } from '_api/DormManage/College/index.js'

export default {
  data() {
    return {
      activeName: 'first',
      showList: true,
      flowList: "",
      // 查询参数
      queryParams: {
        current: 0,
        pageSize: 10,
        starteTime: "",
        endTime: "",
        businessState: "",
        businessType: "1",
        collegeId: "",
        name: ""
      },
      tableData: [],
      total: 0,
      timeNow: "",
      stu: {},
      oldInfo: {},
      newInfo: {},
      form: {
        name: "",
        businessState: "",
        businessType: "4",
        current: 0,
        field: "",
        order: "",
        collegeId: "",
        pageSize: 10
      },
      tableDataCollege: [],
      totalCollege: 0,
      showDetail: false,
      //  申请人信息
      userInfo: "",
      // 审批详情
      examine: [],
      showSignSelf: false,
      showSignOther: false,
      nowImgUrl: "",
      CollegeName: [],
      clientRole: ""
    }
  },
  methods: {
    showSign(e) {
      // console.log(e);
      this.nowImgUrl = e
      this.showSignOther = true
    },
    goDetailCollege(e) {
      this.userInfo = ""
      this.showDetail = true
      lookDetail({ businessId: e }).then(res => {
        if (res.data.success == true) {
          this.userInfo = res.data.data
          this.examine = res.data.data.verificationList
        }
      })
    },
    //获取当前时间
    getCurrentTime() {
      var _this = this;
      let yy = new Date().getFullYear();
      let mm = new Date().getMonth() + 1;
      let dd = new Date().getDate();
      let hh = new Date().getHours();
      let mf = new Date().getMinutes() < 10 ? '0' + new Date().getMinutes() : new Date().getMinutes();
      let ss = new Date().getSeconds() < 10 ? '0' + new Date().getSeconds() : new Date().getSeconds();
      _this.gettime = yy + '-' + mm + '-' + dd + ' ' + hh + ':' + mf + ':' + ss;
      this.timeNow = _this.gettime
    },
    exportExcel() {
      // if (this.queryParams.businessState != '1') {
      //   this.$message.info('请将申请状态设置为 已通过！')
      //   return false
      // }
      exportExcel(this.queryParams).then(res => {
        const link = document.createElement('a')  //创建a标签
        const blob = new Blob([res.data], { type: 'application/vnd.ms-excel' }) //设置文件流
        link.style.display = 'none'// 设置连接
        link.href = URL.createObjectURL(blob)  //将文件流转化为blob地址
        this.getCurrentTime()
        if (this.queryParams.businessType == "1") {
          link.download = '入住申请报表_' + this.timeNow
        }
        if (this.queryParams.businessType == "2") {
          link.download = '退宿申请报表_' + this.timeNow
        }
        if (this.queryParams.businessType == "3") {
          link.download = '调寝申请报表_' + this.timeNow
        }
        document.body.appendChild(link) // 模拟点击事件
        link.click()  //设置点击事件
        this.$message.success('导出成功！')
      })
    },
    handleClickTab(event) {
      // console.log(event);
      if (event.name == "first") {
        this.queryParams.businessType = "1"
        this.getList()
      }
      if (event.name == "second") {
        this.queryParams.businessType = "2"
        this.getList()
      }
      if (event.name == "third") {
        this.queryParams.businessType = "3"
        this.getList()
      }
      if (event.name == "fourth") {
        this.getListCollege()
      }
    },
    handleCurrentChange(e) {
      //当前页
      this.queryParams.current = (e - 1) * (this.queryParams.pageSize)
      this.getList()
    },
    handleSizeChange(e) {
      this.queryParams.pageSize = e
      this.getList()
    },
    handleCurrentChangeCollege(e) {
      //当前页
      this.form.current = (e - 1) * (this.form.pageSize)
      this.getListCollege()
    },
    handleSizeChangeCollege(e) {
      this.form.pageSize = e
      this.getListCollege()
    },
    reset() {
      this.queryParams.current = 0
      this.queryParams.pageSize = 10
      this.queryParams.name = ""
      this.queryParams.starteTime = ""
      this.queryParams.endTime = ""
      this.queryParams.businessState = ""
      // this.queryParams.collegeId = ""
      this.getList()
    },
    resetCollege() {
      this.form = {
        // collegeId: "",
        businessState: "",
        businessType: 4,
        starteTime: "",
        current: 0,
        field: "",
        order: "",
        pageSize: 10
      }
      this.getListCollege()
    },
    // 处理事务
    handleTask(e) {
      this.formFinish = e
      // this.dialogHandle = true
      var query = { processInstanceId: e.pid }
      modelView(query).then(res => {
        this.xmlString = res.data.data.xml
        var flows = []
        res.data.data.flow.forEach(item => {
          flows.unshift(item)
        })
        flows.forEach(item => {
          if (item.endTime) {
            var date = new Date(item.endTime);
            var Y = date.getFullYear() + '-';
            var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
            var D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + ' ';
            var h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
            var m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
            var s = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();
            item.endTime = Y + M + D + h + m + s;
          }
        })
        this.flowList = flows
        this.isSelectBed = res.data.data.isSelectBed
        this.showList = false
      })
      getStuInfo({
        pid: e.pid,
        type: Number(this.queryParams.businessType)
      }).then(res => {
        this.stu = res.data.data.stu
        this.oldInfo = res.data.data.oldInfo
        this.newInfo = res.data.data.newInfo
      })
    },
    
    // 删除
    removeTask(e) {
      let deleteName= this.activeName == 'first' ? '入住申请' : this.activeName == 'second' ? '退宿申请' :this.activeName == 'third' ? '调寝申请' : this.activeName == 'fourth' ? '修改院系申请': '入住申请';
      this.$confirm('此操作将删除该'+deleteName+', 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        // removeDetail(e).then(res => {
        //   if (res.status == 200) {
        //     this.$message({
        //       message: '删除成功!',
        //       duration: 1000,
        //       type: 'success',
        //       onClose: () => {
        //         this.reset()
        //       }
        //     })
        //   }
        // })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    },
    //获取学院名称
    getCollegeName() {
      getCollegeName().then(res => {
        if (res.data.success == true) {
          this.CollegeName = res.data.data
          if (window.localStorage.getItem('clientRole') == 2) {
            this.CollegeName.forEach(item => {
              if (item.name == window.localStorage.getItem('collegeName')) {
                this.form.collegeId = item.id
                this.queryParams.collegeId = item.id

              }
            })
          }
          this.getList()
        }
      })
    },
    // 入住 调寝 退宿 列表查询
    getList() {
      getList(this.queryParams).then(res => {
        if (res.data.success == true) {
          this.tableData = res.data.data.list
          this.total = res.data.data.total
        } else {
          this.tableData = res.data.data
          this.total = 0
          this.$message.info(res.data.message)
        }
      })
    },
    //修改院系 列表查询
    getListCollege() {
      getListApply(
        this.form
      ).then(res => {
        console.log(res)
        if (res.data.success == true) {
          var list = res.data.data.list
          list.forEach(item => {
            if (item.campusName == null) {
              item.campusName = ""
            }
            if (item.buildName == null) {
              item.buildName = ""
            }
            if (item.roomNum == null) {
              item.roomNum = ""
            }
            if (item.bedCode == null) {
              item.bedCode = ""
            }
            item.roomNum = item.campusName + item.buildName + item.roomNum + item.bedCode
            // var Time=[]
            // item.time.forEach(item => {
            //   if (item <= 9) {
            //   item = "0" + item
            //   }
            //   Time.push(item)
            // })
            // item.time=Time[0] + "-" + Time[1] + "-" + Time[2] + " " + Time[3] + ":" + Time[4] + ":" + Time[5]
          })
          this.tableDataCollege = list
          this.totalCollege = res.data.data.total
        } else {
          this.tableDataCollege = res.data.data
          this.totalCollege = 0
          this.$message.info(res.data.message)
        }
      })
    }
  },
  created() {
    this.clientRole = window.localStorage.getItem('clientRole')
    this.getCollegeName()
  },
}
</script>

<style lang="scss" scoped>
.pagination {
  float: right;
  margin-top: 10px;
}

#colorTitle {
  color: #ffffff;
  background-color: rgb(233, 182, 44);
  padding: 2px 6px;
  border-radius: 4px;
}

.infoItem {
  margin-top: 10px;
}

.exportBtn {
  margin-top: 10px;
}
</style>
